<template>
  <div class="oa-form__table">
    <h5>{{approve.name}}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>{{approve.name}}<span v-if="approve && approve.code">{{approve.code}}</span></td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">
            新建{{approve.name}}
          </span>
          <span v-else>
            {{approve.approve_name}}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{approve.name}}</span>
      <span v-else>
            {{approve.approve_name}}
      </span>
    </h3>
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td class="_name">
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td class="_name">业务人员</td>
        <td width="20%">
          <el-select v-model="value" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <td class="_name">客户名称</td>
        <td width="20%">
          <el-input placeholder="客户名称" v-model="obj.obj23" :disabled="obj.obj23Flag"/>
        </td>
        <td class="_name">合同编号</td>
        <td width="20%">
          <el-input placeholder="合同编号" v-model="obj.obj24" :disabled="obj.obj24Flag"/>
        </td>
      </tr>
      <tr>
        <td rowspan="6" class="_name">媒体类别</td>
        <td class="_name">岛内候车亭大牌固定</td>
        <td><el-input placeholder="座" v-model="seat1"  :disabled="$route.query.from != 'new'"/>座</td>
        <td class="_name">岛内候车亭大牌滚动</td>
        <td><el-input placeholder="座" v-model="seat2"  :disabled="$route.query.from != 'new'"/>座</td>
        <td class="_name">岛内候车亭小牌</td>
        <td><el-input placeholder="座" v-model="seat3"  :disabled="$route.query.from != 'new'"/>座</td>
      </tr>
      <tr>
        <td class="_name">岛外候车亭固定</td>
        <td><el-input placeholder="座" v-model="seat4"  :disabled="$route.query.from != 'new'"/>座</td>
        <td class="_name">岛外候车亭滚动</td>
        <td><el-input placeholder="座" v-model="seat5"  :disabled="$route.query.from != 'new'"/>座</td>
        <td class="_name">岛外候车亭小牌</td>
        <td><el-input placeholder="座" v-model="seat6"  :disabled="$route.query.from != 'new'"/>座</td>
      </tr>
      <tr>
        <td class="_name">外购候车亭固定</td>
        <td><el-input placeholder="座" v-model="seat7"  :disabled="$route.query.from != 'new'"/>座</td>
        <td class="_name">外购候车亭滚动</td>
        <td><el-input placeholder="座" v-model="seat8"  :disabled="$route.query.from != 'new'"/>座</td>
        <td class="_name">外购候车亭小牌</td>
        <td><el-input placeholder="座" v-model="seat9"  :disabled="$route.query.from != 'new'"/>座</td>
      </tr>
      <tr>
        <td class="_name">旧款普通路名牌</td>
        <td><el-input placeholder="座" v-model="seat10"  :disabled="$route.query.from != 'new'"/>座</td>
        <td class="_name">A款路名牌</td>
        <td><el-input placeholder="座" v-model="seat12"  :disabled="$route.query.from != 'new'"/>座</td>
        <td class="_name">B款路名牌</td>
        <td><el-input placeholder="座" v-model="seat11"  :disabled="$route.query.from != 'new'"/>座</td>
      </tr>
      <tr>
        <td class="_name">站名牌</td>
        <td colspan="5"><el-input placeholder="座" v-model="seat13"  :disabled="$route.query.from != 'new'"/>座</td>
      </tr>
      <tr>
        <td class="_name">快递柜</td>
        <td colspan="5"><el-input placeholder="座" v-model="obj.obj926"  :disabled="obj.obj926Flag"/>座</td>
      </tr>
      <tr>
        <td rowspan="5" class="_name">媒体设置</td>
        <td class="_name">具体发布时间</td>
        <td width="20%">
          <!-- <el-input placeholder="媒体购买" v-model="media" :disabled="$route.query.from != 'new'"/> -->
          <el-input placeholder="具体发布时间" v-model="obj.obj36"  :disabled="obj.obj36Flag"/>
        </td>
        <td class="_name">预计发布日</td>
        <td>
          <el-date-picker
            v-model="estimate"
            :disabled="$route.query.from != 'new'"
            value-format="yyyy-MM-dd"
            type="date"
            placeholder="预计发布日">
          </el-date-picker>
        </td>
        <td class="_name">发布期限</td>
        <td colspan="2" >
          <el-input placeholder="发布期限" v-model="issue" :disabled="$route.query.from != 'new'"/>
        </td>
      </tr>
      <tr>
        <td class="_name">预定点位确认</td>
        <td>
          <el-input placeholder="预定点位确认" v-model="yuding"  :disabled="yudingFlag"/>
        </td>
        <td class="_name">点位套餐</td>
        <td>
          <el-input placeholder="点位套餐" v-model="dianwei"  :disabled="$route.query.from != 'new'"/>
        </td>
        <td class="_name">预定点位最终确认</td>
        <td colspan="2">
          <el-input placeholder="预定点位最终确认" v-model="fanilly" :disabled="fanillyFlag"/>
        </td>
      </tr>
      <tr>
        <td class="_name">版面内容</td>
        <td>
          <el-input placeholder="版面内容" v-model="copyright"  :disabled="$route.query.from != 'new'"/>
        </td>
        <td class="_name">优惠条款</td>
        <td colspan="4">
          <el-input placeholder="优惠条款" v-model="discount"  :disabled="$route.query.from != 'new'"/>
        </td>
      </tr>
    </table>
    <history :process="process"></history>
    <p class="oa-form__table-hd">首付款到款确认</p>
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td class="_name">合同总金</td>
        <td>
           <el-input placeholder="合同总金额" v-model="htzje"  :disabled="htzjeFlag"/>
        </td>
        <td class="_name">首付款金额</td>
        <td>
          <el-input placeholder="首付款金额" v-model="sfkje"  :disabled="sfkjeFlag"/>
        </td>
        <td class="_name">开票时间</td>
        <td>
          <el-date-picker
            v-model="kpsj"
            :disabled="kpsjFlag"
            value-format="yyyy-MM-dd"
            type="date"
            placeholder="开票时间">
          </el-date-picker>
        </td>
      </tr>
      <tr>
        <td class="_name">发票号</td>
        <td>
          <el-input placeholder="发票号" v-model="fph"  :disabled="fphFlag"/>
        </td>
        <td class="_name">发票金额</td>
        <td>
          <el-input placeholder="发票金额" v-model="fpje"  :disabled="fpjeFlag"/>
        </td>
        <td class="_name">首付款到款时间</td>
        <td>
          <el-date-picker
            v-model="sfktime"
            :disabled="sfktimeFlag"
            value-format="yyyy-MM-dd"
            type="date"
            placeholder="首付款到款时间">
          </el-date-picker>
        </td>
      </tr>
    </table>
    <p class="oa-form__table-hd">剩余款项到款情况</p>
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tbody v-for = "item in 3" :key = "item">
         <tr>
          <td class="_name">{{`第${indexes[item-1]}期应付金额`}}</td>
          <td>
            <el-input placeholder="应付金额" v-model="money[`yfje${item+1}`]"  :disabled="money[`yfje${item+1}Flag`]"/>
          </td>
          <td class="_name">开票时间</td>
          <td>
            <el-date-picker
              v-model="money[`kpsj${item+1}`]"
              :disabled="money[`kpsj${item+1}Flag`]"
              value-format="yyyy-MM-dd"
              type="date"
              placeholder="开票时间">
            </el-date-picker>
          </td>
          <td class="_name">发票号</td>
          <td>
            <el-input placeholder="发票号" v-model="money[`fph${item+1}`]"  :disabled="money[`fph${item+1}Flag`]"/>
          </td>
        </tr>
        <tr>
          <td class="_name">发票金额</td>
          <td>
            <el-input placeholder="发票金额" v-model="money[`fpje${item+1}`]"  :disabled="money[`fpje${item+1}Flag`]"/>
          </td>
          <td class="_name">{{`第${indexes[item-1]}期款到款时间`}}<br /></td>
          <td>
            <el-date-picker
              v-model="money[`dksj${item+1}`]"
              :disabled="money[`dksj${item+1}Flag`]"
              value-format="yyyy-MM-dd"
              type="date"
              placeholder="到款时间">
            </el-date-picker>
          </td>
          <td class="_name">备注</td>
          <td>
            <el-input placeholder="备注" v-model="money[`sybz${item+1}`]"  :disabled="money[`sybz${item+1}Flag`]"/>
          </td>
        </tr>
      </tbody>
    </table>
    <!-- <p class="oa-form__table-hd">特殊情况申请表</p>
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td class="_name">申请人</td>
        <td>&nbsp;</td>
        <td class="_name">日期</td>
        <td>&nbsp;</td>
        <td class="_name">合同总金额</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="6">原因1：合同未归档，款未到</td>
      </tr>
      <tr>
        <td class="_name">预计合同归档时间</td>
        <td>&nbsp;</td>
        <td class="_name">预计到款时间</td>
        <td>&nbsp;</td>
        <td class="_name">备注</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="6">原因2：合同已归档，款未到</td>
      </tr>
      <tr>
        <td class="_name">合同已归档时间</td>
        <td>&nbsp;</td>
        <td class="_name">预计到款时间</td>
        <td>&nbsp;</td>
        <td class="_name">备注</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="6">原因3：合同未归档，款已到</td>
      </tr>
      <tr>
        <td class="_name">预计合同归档时间</td>
        <td>&nbsp;</td>
        <td class="_name">首付款到款时间</td>
        <td>&nbsp;</td>
        <td class="_name">备注</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="6">原因4：其他特殊原因</td>
      </tr>
      <tr>
        <td colspan="6">123</td>
      </tr>
      <tr>
        <td class="_name">财务审核</td>
        <td>&nbsp;</td>
        <td class="_name">分管副总审批</td>
        <td>&nbsp;</td>
        <td class="_name">总经理审批</td>
        <td>&nbsp;</td>
      </tr>
    </table> -->
    <p class="oa-form__table-hd">喷绘记录</p>
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td class="_name">下单日期</td>
        <td class="_name">广告内容</td>
        <td class="_name">尺寸</td>
        <td class="_name">数量</td>
        <td class="_name">喷绘性质</td>
        <td class="_name">上刊时间或换画时间派单上画</td>
        <td class="_name">供应商</td>
        <td class="_name">备注</td>
      </tr>
      <tr v-for="( item, index) in 8" :key="index">
        <td>
          <el-date-picker
            v-model="obj['xdrq' + item]"
            :disabled="obj['xdrq' + item + 'Flag']"
            value-format="yyyy-MM-dd"
            type="date"
            placeholder="下单日期">
          </el-date-picker>
        </td>
        <td>
          <el-input v-model="obj['ggnr' + item]"  :disabled="obj['ggnr' + item + 'Flag']" placeholder="广告内容"></el-input>
        </td>
        <td>
           <el-input v-model="obj['cc' + item]"  :disabled="obj['cc' + item + 'Flag']" placeholder="尺寸"></el-input>
        </td>
        <td>
           <el-input v-model="obj['num' + item]"  :disabled="obj['num' + item + 'Flag']" placeholder="数量"></el-input>
        </td>
        <td>
          <el-input v-model="obj['phxz' + item]"  :disabled="obj['phxz' + item + 'Flag']" placeholder="喷绘性质"></el-input>
        </td>
        <td>
          <el-date-picker
            v-model="obj['sksj' + item]"
            :disabled="obj['sksj' + item + 'Flag']"
            value-format="yyyy-MM-dd"
            type="date"
            placeholder="上刊时间或换画时间派单上画">
          </el-date-picker>
        </td>
        <td>
          <el-input v-model="obj['gys' + item]"  :disabled="obj['gys' + item + 'Flag']" placeholder="供应商"></el-input>
        </td>
        <td>
          <el-input v-model="obj['phbz' + item]"  :disabled="obj['phbz' + item + 'Flag']" placeholder="备注"></el-input>
        </td>
      </tr>
    </table>
    <files></files>
    <div class="oa-form__table-hd">附件1（候车亭路名牌，发布点位明细)</div>
    <table width="100%" border="1" cellspacing="0" cellpadding="0" style="text-align:center" v-if="passListArr.length !== 0">
      <tr>
        <td colspan="9">
          <!--发起时可操作-->
           <el-form :inline="true" :model="formInline" class="demo-form-inline" id="demo-form-inline">
              <el-form-item label="编号">
                <el-select v-model="formInline.region" placeholder="编号" :disabled="this.$route.query.from !== 'new'">
                  <el-option  :label="`${item.id}-${item.truename}-${item.customer}`" :value="item.id" v-for="(item, index) in passListArr" :key="index"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" :disabled="btndisabled" @click="onSubmit">查询</el-button>
              </el-form-item>
            </el-form>
        </td>
      </tr>
      <tr>
        <td class="_name">序号</td>
        <td class="_name">路段</td>
        <td class="_name">点位</td>
        <td class="_name">发布类型</td>
        <td class="_name">编号</td>
        <td class="_name">级别</td>
        <td class="_name">是否亮灯</td>
        <td class="_name">可调客户</td>
        <td class="_name">备注</td>
      </tr>
      <tbody v-if="importArr.length !== 0">
        <tr v-for="(item, index) in importArr" :key="index">
          <td>{{importArr.length - index}}</td>
          <td>{{item.luduan}}</td>
          <td>{{item.title}}</td>
          <td>
            <span v-if="item.cate_name">
              {{item.cate_name}}({{item.size}})
            </span>
            <span v-else>--</span>
          </td>
          <td>
            <span v-if="item.code">{{item.code}}</span>
            <span v-else>--</span>
          </td>
          <td>
            <span v-if="item.rank">{{item.rank}}</span>
            <span v-else>--</span>
          </td>
          <td>
            <el-switch
              :value ="item.is_light === 1"
              active-color="#13ce66"
              inactive-color="#ccc">
            </el-switch>
          </td>
          <td>
            <span v-if="item.customer_name">{{item.customer_name}}</span>
            <span v-else>--</span>
          </td>
          <td>
            <span v-if="item.remark">{{item.remark}}</span>
            <span v-else>--</span>
          </td>
        </tr>
      </tbody>
      <tr v-else>
         <td colspan="8">暂无数据</td>
      </tr>
    </table>
    <p class="oa-form__table-hd">附表：2  媒体外购申请单（时间：xxxxx）</p>
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td class="_name">填表人</td>
        <td>
           <el-input v-model="wm.wm611"  :disabled="this.$route.query.from !== 'new'" placeholder="填表人"></el-input>
        </td>
        <td class="_name">部门</td>
        <td>
          <el-input v-model="wm.wm612"  :disabled="this.$route.query.from !== 'new'" placeholder="部门"></el-input>
        </td>
        <td class="_name">客户名称</td>
        <td>
          <el-input v-model="wm.wm613"  :disabled="this.$route.query.from !== 'new'" placeholder="客户名称"></el-input>
        </td>
      </tr>
      <tr>
        <td class="_name">预定发布期</td>
        <td>
          <el-input v-model="wm.wm614"  :disabled="this.$route.query.from !== 'new'" placeholder="预定发布期"></el-input>
        </td>
        <td class="_name">外购数量</td>
        <td>
          <el-input v-model="wm.wm615"  :disabled="this.$route.query.from !== 'new'" placeholder="外购数量"></el-input>
        </td>
        <td class="_name">发布期限</td>
        <td>
          <el-input v-model="wm.wm616"  :disabled="this.$route.query.from !== 'new'" placeholder="发布期限"></el-input>
        </td>
      </tr>
      <tr>
        <td class="_name">外购单位</td>
        <td>
          <el-input v-model="wm.wm617"  :disabled="this.$route.query.from !== 'new'" placeholder="外购单位"></el-input>
        </td>
        <td class="_name">外购单价</td>
        <td>
          <el-input v-model="wm.wm618"  :disabled="this.$route.query.from !== 'new'" placeholder="外购单价"></el-input>
        </td>
        <td class="_name">外购总金额</td>
        <td>
          <el-input v-model="wm.wm619"  :disabled="this.$route.query.from !== 'new'" placeholder="外购总金额"></el-input>
        </td>
      </tr>
      <tr>
        <td class="_name">合同单价</td>
        <td>
          <el-input v-model="wm.wm620"  :disabled="this.$route.query.from !== 'new'" placeholder="合同单价"></el-input>
        </td>
        <td class="_name">财务审批</td>
        <td>
          <el-input v-model="wm.wm621"  :disabled="this.$route.query.from !== 'new'" placeholder="财务审批"></el-input>
        </td>
        <td class="_name">外购确认</td>
        <td>
          <el-input v-model="wm.wm622"  :disabled="this.$route.query.from !== 'new'" placeholder="外购确认"></el-input>
        </td>
      </tr>
      <tr>
        <td class="_name">外购单位 </td>
        <td>
          <el-input v-model="wm.wm623"  :disabled="this.$route.query.from !== 'new'" placeholder="外购单位"></el-input>
        </td>
        <td class="_name">外购单价</td>
        <td>
          <el-input v-model="wm.wm624"  :disabled="this.$route.query.from !== 'new'" placeholder="外购单价"></el-input>
        </td>
        <td class="_name">外购总金额 </td>
        <td>
          <el-input v-model="wm.wm625"  :disabled="this.$route.query.from !== 'new'" placeholder="外购总金额"></el-input>
        </td>
      </tr>
      <!-- <tr>
        <td class="_name">备注</td>
        <td colspan="5"></td>
      </tr> -->
    </table>
  </div>
</template>
<script>
import { save, info, getAutoKey, Import, passList } from '@/api/oa/index.js'
import mixin from '@/mixins/index.js'
import history from './components/process'
import files from './components/files'
import { getToDayFunc } from '@/utils/domUtils.js'
const obj = {}
for (let i = 1; i < 11; i++) {
  obj['xdrq' + i] = ''
  obj[`xdrq${i}Flag`] = true
  obj['ggnr' + i] = ''
  obj[`ggnr${i}Flag`] = true
  obj['cc' + i] = ''
  obj[`cc${i}Flag`] = true
  obj['num' + i] = ''
  obj[`num${i}Flag`] = true
  obj['phxz' + i] = ''
  obj[`phxz${i}Flag`] = true
  obj['sksj' + i] = ''
  obj[`sksj${i}Flag`] = true
  obj['gys' + i] = ''
  obj[`gys${i}Flag`] = true
  obj['phbz' + i] = ''
  obj[`phbz${i}Flag`] = true
}
for (let i = 23; i < 37; i++) {
  obj['obj' + i] = ''
  obj[`obj${i}Flag`] = true
}
obj.obj926 = ''
obj.obj926Flag = true
console.log(obj)
const money = {}
const indexes = ['二', '三', '四']
for (let j = 0; j < 3; j++) {
  money[`yfje${j + 2}`] = ''
  money[`yfje${j + 2}Flag`] = true
  money[`kpsj${j + 2}`] = ''
  money[`kpsj${j + 2}Flag`] = true
  money[`fph${j + 2}`] = ''
  money[`fph${j + 2}Flag`] = true
  money[`fpje${j + 2}`] = ''
  money[`fpje${j + 2}Flag`] = true
  money[`dksj${j + 2}`] = ''
  money[`dksj${j + 2}Flag`] = true
  money[`sybz${j + 2}`] = ''
  money[`sybz${j + 2}Flag`] = true
}
const wm = {}
for (let m = 611; m <= 625; m++) {
  wm[`wm${m}`] = ''
}
export default {
  mixins: [mixin],
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'departments', 'addDofield', 'process'],
  data () {
    return {
      checkList: [],
      radio: 1,
      contents: '',
      reason: '',
      flag: false,
      value: '',
      department: '',
      truename: '',
      disabled: false,
      obj,
      money,
      indexes,
      wm,
      tableName: '',
      tableNum: '',
      customer: '',
      hetong: '',
      seat1: '',
      seat2: '',
      seat3: '',
      seat4: '',
      seat5: '',
      seat6: '',
      seat7: '',
      seat8: '',
      seat9: '',
      seat10: '',
      seat11: '',
      seat12: '',
      seat13: '',
      media: '',
      estimate: '',
      issue: '',
      yuding: '',
      dianwei: '',
      fanilly: '',
      copyright: '',
      discount: '',
      yudingFlag: true,
      fanillyFlag: true,
      field_ids: [],
      field_vals: [],
      htzje: '',
      htzjeFlag: true,
      sfkje: '',
      sfkjeFlag: true,
      sfktime: '',
      sfktimeFlag: true,
      fph: '',
      fphFlag: true,
      fpje: '',
      fpjeFlag: true,
      kpsj: '',
      kpsjFlag: true,
      autoField: [],
      aa: '',
      file_paths: [],
      file_names: [],
      importArr: [],
      formInline: {
        region: 0
      },
      passListArr: [],
      btndisabled: this.$route.query.from !== 'new'
    }
  },
  created () {
    if (this.$route.query.from === 'new') {
      this.passListDo()
      this.disabled = true
    } else {
      this.infoFunc()
    }
    // this.passListDo()
    this.reset()
  },
  mounted () {
  },
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    }
  },
  watch: {
    addDofield () {
      this.addDofieldRender()
    }
  },
  methods: {
    importDo () {
      const params = {
        id: this.formInline.region
      }
      Import(params).then(res => {
        const { status, data } = res
        if (status) {
          this.importArr = data
        }
      })
    },
    passListDo () {
      const params = {
        openid: window.localStorage.getItem('token')
      }
      passList(params).then(res => {
        const { status, data } = res
        if (status) {
          this.passListArr = data
          if (data.length > 0) {
            if (!this.formInline.region) {
              this.formInline.region = data[0].id
            }
            this.importDo()
          }
        }
      })
    },
    onSubmit () {
      if (!this.flag) {
        this.flag = true
        this.importDo()
      }
      setTimeout(() => {
        this.flag = false
      }, 2000)
    },
    renderCustom () {
      console.log('change')
      this.autoField && this.autoField.forEach(e => {
        this.judge(e)
        if (e.val) {
          this.field_ids.push(e.approve_field_id)
          this.field_vals.push(e.val)
        }
        return e
      })
      console.log(this.field_ids, this.field_vals)
    },
    getData () {
      if (this.uploadArr.length > 0) {
        this.uploadArr.forEach(item => {
          this.file_paths.push(item.path)
          this.file_names.push(item.name)
        })
      }
      const params = {
        // token: window.localStorage.getItem('token'),
        openid: window.localStorage.getItem('token'),
        reason: this.reason,
        approve_id: this.approve.id,
        department_id: this.department,
        apply_date: this.applyTime,
        truename: this.truename,
        import_id: this.formInline.region
      }
      // if (this.file_paths.length > 0 && this.$route.query.from !== 'new') {
      //   const paths = new Set(this.file_paths)
      //   const names = new Set(this.file_names)
      //   params.file_paths = Array.from(paths).join()
      //   params.file_names = Array.from(names).join()
      // }
      const paths = new Set(this.file_paths)
      const names = new Set(this.file_names)
      params.file_paths = Array.from(paths).join()
      params.file_names = Array.from(names).join()
      this.addDofieldRender()
      params.field_ids = this.field_ids.join()
      params.field_vals = this.field_vals.join()
      if (!this.reason) {
        this.$message.error('请输入申请原因')
        return false
      }
      if (!this.value) {
        this.$message.error('请选择业务人员')
        return false
      }
      save(params).then((res) => {
        const { status } = res
        if (status) {
          this.$message.error('提交成功')
          this.$router.push({ name: 'oaList', query: { activeName: 4 } })
        }
      })
      this.$store.commit('getUpload', [])
    },
    infoFunc () {
      const params = {
        // token: window.localStorage.getItem('token'),
        openid: window.localStorage.getItem('token'),
        approve_id: this.approve.approve_id,
        workflow_id: this.approve.workflow_id
      }
      info(params).then(res => {
        const { status, data: { workflow }, data: { fields }, data: { node } } = res
        if (status) {
          this.reason = workflow.reason
          this.contents = workflow.contents
          this.value = workflow.truename
          this.department = workflow.department_id
          this.formInline.region = workflow.import_id
          window.localStorage.setItem('approve_node_id', workflow.approve_node_id)
          window.localStorage.setItem('is_end', workflow.is_end)
          if (fields && fields.length > 0) {
            this.fieldsInfo(fields)
          }
          if (node && node.length > 0) {
            this.nodeInfo(node)
          }
          this.getAutoKey(workflow.approve_node_id)
          this.passListDo()
        }
      })
    },
    nodeInfo (node) {
      node && node.forEach(e => {
        if (e.name === '到款确认') {
          e.fields && e.fields.forEach(j => {
            for (let i = 0; i < 3; i++) {
              if (j.field_name === `第${indexes[i]}期应付金额`) {
                this.money[`yfje${i + 2}`] = j.field_val
              }
              if (j.field_name === `第${indexes[i]}期开票时间`) {
                this.money[`kpsj${i + 2}`] = j.field_val
              }
              if (j.field_name === `第${indexes[i]}期发票号`) {
                this.money[`fph${i + 2}`] = j.field_val
              }
              if (j.field_name === `第${indexes[i]}期发票金额`) {
                this.money[`fpje${i + 2}`] = j.field_val
              }
              if (j.field_name === `第${indexes[i]}期款到款时间`) {
                this.money[`dksj${i + 2}`] = j.field_val
              }
              if (j.field_name === `第${indexes[i]}期备注`) {
                this.money[`sybz${i + 2}`] = j.field_val
              }
            }
            return j
          })
        }
        if (e.name === '首付款确认') {
          e.fields && e.fields.forEach(j => {
            for (let i = 0; i < 3; i++) {
              if (j.field_name === '合同总金额') {
                this.htzje = j.field_val
              }
              if (j.field_name === '首付款金额') {
                this.sfkje = j.field_val
              }
              if (j.field_name === '首付款到款时间') {
                this.sfktime = j.field_val
              }
              if (j.field_name === '发票号') {
                this.fph = j.field_val
              }
              if (j.field_name === '发票金额') {
                this.fpje = j.field_val
              }
              if (j.field_name === '开票时间') {
                this.kpsj = j.field_val
              }
            }
            return j
          })
        }
        if (e.name === '下单制作' || e.name === '喷绘下单') {
          e.fields && e.fields.forEach(j => {
            for (let i = 1; i < 11; i++) {
              if (j.field_name === `下单日期${i}`) {
                this.obj[`xdrq${i}`] = j.field_val
              }
              if (j.field_name === `广告内容${i}`) {
                this.obj[`ggnr${i}`] = j.field_val
              }
              if (j.field_name === `尺寸${i}`) {
                this.obj[`cc${i}`] = j.field_val
              }
              if (j.field_name === `数量${i}`) {
                this.obj[`num${i}`] = j.field_val
              }
              if (j.field_name === `喷绘性质${i}`) {
                this.obj[`phxz${i}`] = j.field_val
              }
              if (j.field_name === `上刊时间或换画时间派单上画${i}`) {
                this.obj[`sksj${i}`] = j.field_val
              }
              if (j.field_name === `供应商${i}`) {
                this.obj[`gys${i}`] = j.field_val
              }
              if (j.field_name === `喷绘记录备注${i}`) {
                this.obj[`phbz${i}`] = j.field_val
              }
            }
            return j
          })
        }
        if (e.name === '派单上画及验收函拟定') {
          e.fields && e.fields.forEach(j => {
            if (j.field_name === '具体发布时间') {
              this.obj.obj36 = j.field_val
            }
            return j
          })
        }
        if (e.name === '合同拟定') {
          e.fields && e.fields.forEach(j => {
            if (j.field_id >= 23 && j.field_id <= 24) {
              this.obj[`obj${j.field_id}`] = j.field_val
            }
          })
        }
        return e
      })
    },
    //  info 中fields字段
    fieldsInfo (fields) {
      fields && fields.forEach(e => {
        if (e.field_id <= 625 && e.field_id >= 611) {
          this.wm[`wm${e.field_id}`] = e.field_val
        }
        if (e.field_id <= 24 && e.field_id >= 23) {
          this.obj['obj' + e.field_id] = e.field_val
        }
        if (e.field_name === '申请人') {
          this.value = e.field_val
        }
        if (e.field_name === '客户名称') {
          this.customer = e.field_val
        }
        if (e.field_name === '合同编号') {
          this.hetong = e.field_val
        }
        if (e.field_name === '岛内候车亭大牌固定') {
          this.seat1 = e.field_val
        }
        if (e.field_name === '岛内候车亭大牌滚动') {
          this.seat2 = e.field_val
        }
        if (e.field_name === '岛内候车亭小牌') {
          this.seat3 = e.field_val
        }
        if (e.field_name === '岛外候车亭大牌') {
          this.seat4 = e.field_val
        }
        if (e.field_name === '岛外候车亭滚动') {
          this.seat5 = e.field_val
        }
        if (e.field_name === '岛外候车亭小牌') {
          this.seat6 = e.field_val
        }
        if (e.field_name === '外购候车亭大牌') {
          this.seat7 = e.field_val
        }
        if (e.field_name === '外购候车亭滚动') {
          this.seat8 = e.field_val
        }
        if (e.field_name === '外购候车亭小牌') {
          this.seat9 = e.field_val
        }
        if (e.field_name === '旧款普通路名牌') {
          this.seat10 = e.field_val
        }
        if (e.field_name === 'B款路名牌') {
          this.seat11 = e.field_val
        }
        if (e.field_name === 'A款路名牌') {
          this.seat12 = e.field_val
        }
        if (e.field_name === '站名牌') {
          this.seat13 = e.field_val
        }
        if (e.field_name === '具体发布时间') {
          this.obj.obj36 = e.field_val
        }
        if (e.field_id === 926) {
          this.obj.obj926 = e.field_val
        }
        if (e.field_name === '预计发布日') {
          this.estimate = e.field_val
        }
        if (e.field_name === '发布期限') {
          this.issue = e.field_val
        }
        if (e.field_name === '预定点位确认') {
          this.yuding = e.field_val
        }
        if (e.field_name === '点位套餐') {
          this.dianwei = e.field_val
        }
        if (e.field_name === '预定点位最终确认') {
          this.fanilly = e.field_val
        }
        if (e.field_name === '版面内容') {
          this.copyright = e.field_val
        }
        if (e.field_name === '优惠条款') {
          this.discount = e.field_val
        }
        if (e.field_name === '合同总金额') {
          this.htzje = e.field_val
        }
        if (e.field_name === '首付款金额') {
          this.sfkje = e.field_val
        }
        if (e.field_name === '发票号') {
          this.fph = e.field_val
        }
        if (e.field_name === '发票金额') {
          this.fpje = e.field_val
        }
        if (e.field_name === '首付款到款时间') {
          this.sfktime = e.field_val
        }
        if (e.field_name === '开票时间') {
          this.kpsj = e.field_val
        }
        if (e.field_name === '明细编号') {
          this.formInline.region = Number(e.field_val)
          // this.passListDo()
        }
        for (let i = 1; i < 11; i++) {
          if (e.field_name === `下单日期${i}`) {
            this.obj[`xdrq${i}`] = e.field_val
          }
          if (e.field_name === `广告内容${i}`) {
            this.obj[`ggnr${i}`] = e.field_val
          }
          if (e.field_name === `尺寸${i}`) {
            this.obj[`cc${i}`] = e.field_val
          }
          if (e.field_name === `数量${i}`) {
            this.obj[`num${i}`] = e.field_val
          }
          if (e.field_name === `喷绘性质${i}`) {
            this.obj[`phxz${i}`] = e.field_val
          }
          if (e.field_name === `上刊时间或换画时间派单上画${i}`) {
            this.obj[`sksj${i}`] = e.field_val
          }
          if (e.field_name === `供应商${i}`) {
            this.obj[`gys${i}`] = e.field_val
          }
          if (e.field_name === `喷绘记录备注${i}`) {
            this.obj[`phbz${i}`] = e.field_val
          }
        }
      })
    },
    reset () {
      const obj = {}
      for (let i = 1; i < 11; i++) {
        obj['xdrq' + i] = ''
        obj[`xdrq${i}Flag`] = true
        obj['ggnr' + i] = ''
        obj[`ggnr${i}Flag`] = true
        obj['cc' + i] = ''
        obj[`cc${i}Flag`] = true
        obj['num' + i] = ''
        obj[`num${i}Flag`] = true
        obj['phxz' + i] = ''
        obj[`phxz${i}Flag`] = true
        obj['sksj' + i] = ''
        obj[`sksj${i}Flag`] = true
        obj['gys' + i] = ''
        obj[`gys${i}Flag`] = true
        obj['phbz' + i] = ''
        obj[`phbz${i}Flag`] = true
      }
      for (let i = 23; i < 37; i++) {
        obj['obj' + i] = ''
        obj[`obj${i}Flag`] = true
      }
      obj.obj926 = ''
      obj.obj926Flag = true
      this.obj = obj
      console.log(this.obj)
      const money = {}
      for (let j = 0; j < 3; j++) {
        money[`yfje${j + 2}`] = ''
        money[`yfje${j + 2}Flag`] = true
        money[`kpsj${j + 2}`] = ''
        money[`kpsj${j + 2}Flag`] = true
        money[`fph${j + 2}`] = ''
        money[`fph${j + 2}Flag`] = true
        money[`fpje${j + 2}`] = ''
        money[`fpje${j + 2}Flag`] = true
        money[`dksj${j + 2}`] = ''
        money[`dksj${j + 2}Flag`] = true
        money[`sybz${j + 2}`] = ''
        money[`sybz${j + 2}Flag`] = true
      }
      this.money = money
      const wm = {}
      for (let m = 611; m <= 625; m++) {
        wm[`wm${m}`] = ''
      }
      this.wm = wm
    },
    submitFunc () {
      if (!this.flag) {
        this.flag = true
        this.getData()
        setTimeout(() => {
          this.flag = false
        }, 3000)
      }
    },
    addDofieldRender () {
      this.addDofield && this.addDofield.forEach(e => {
        this.judge(e)
        if (e.val) {
          this.field_ids.push(e.field_id)
          this.field_vals.push(e.val)
        }
        return e
      })
    },
    // 选择申请人
    selectStaff (e) {
      this.truename = e.truename
      this.department = e.department_id
    },
    getAutoKey (id) {
      getAutoKey(id).then(res => {
        const { status, data } = res
        this.autoField = data
        if (status) {
          this.autoField && this.autoField.forEach(e => {
            this.judge(e)
            return e
          })
        }
      })
    },
    judge (e) {
      if (e.field_name === '业务人员') {
        this.$set(e, 'val', this.truename)
      }
      // if (e.field_name === '合同编号') {
      //   this.$set(e, 'val', this.hetong)
      // }
      // if (e.field_name === '客户名称') {
      //   this.$set(e, 'val', this.customer)
      // }
      if (e.field_name === '岛内候车亭大牌固定') {
        this.$set(e, 'val', this.seat1)
      }
      if (e.field_name === '岛内候车亭大牌滚动') {
        this.$set(e, 'val', this.seat2)
      }
      if (e.field_name === '岛内候车亭小牌') {
        this.$set(e, 'val', this.seat3)
      }
      if (e.field_name === '岛外候车亭大牌') {
        this.$set(e, 'val', this.seat4)
      }
      if (e.field_name === '岛外候车亭滚动') {
        this.$set(e, 'val', this.seat5)
      }
      if (e.field_name === '岛外候车亭小牌') {
        this.$set(e, 'val', this.seat6)
      }
      if (e.field_name === '外购候车亭大牌') {
        this.$set(e, 'val', this.seat7)
      }
      if (e.field_name === '外购候车亭滚动') {
        this.$set(e, 'val', this.seat8)
      }
      if (e.field_name === '外购候车亭小牌') {
        this.$set(e, 'val', this.seat9)
      }
      if (e.field_name === '旧款普通路名牌') {
        this.$set(e, 'val', this.seat10)
      }
      if (e.field_name === 'B款路名牌') {
        this.$set(e, 'val', this.seat11)
      }
      if (e.field_name === 'A款路名牌') {
        this.$set(e, 'val', this.seat12)
      }
      if (e.field_name === '站名牌') {
        this.$set(e, 'val', this.seat13)
      }
      if (e.field_name === '具体发布时间') {
        // this.$set(e, 'val', this.media)
        this.$set(e, 'val', this.obj.obj36)
        this.obj.obj36Flag = false
      }
      if (e.field_id === 926) {
        this.$set(e, 'val', this.obj.obj926)
        this.obj.obj926Flag = false
      }
      if (e.field_name === '预计发布日') {
        this.$set(e, 'val', this.estimate)
      }
      if (e.field_name === '发布期限') {
        this.$set(e, 'val', this.issue)
      }
      if (e.field_name === '预定点位确认') {
        this.yudingFlag = false
        this.yuding = this.approve.truename
        this.$set(e, 'val', this.yuding)
      }
      if (e.field_name === '点位套餐') {
        this.$set(e, 'val', this.dianwei)
      }
      if (e.field_name === '预定点位最终确认') {
        this.fanillyFlag = false
        this.fanilly = getToDayFunc()
        this.$set(e, 'val', this.fanilly)
      }
      if (e.field_name === '版面内容') {
        this.$set(e, 'val', this.copyright)
      }
      if (e.field_name === '优惠条款') {
        this.$set(e, 'val', this.discount)
      }
      if (e.field_name === '合同总金额') {
        this.$set(e, 'val', this.htzje)
        this.htzjeFlag = false
      }
      if (e.field_name === '首付款金额') {
        this.$set(e, 'val', this.sfkje)
        this.sfkjeFlag = false
      }
      if (e.field_name === '发票号') {
        this.$set(e, 'val', this.fph)
        this.fphFlag = false
      }
      if (e.field_name === '发票金额') {
        this.$set(e, 'val', this.fpje)
        this.fpjeFlag = false
      }
      if (e.field_name === '首付款到款时间') {
        this.$set(e, 'val', this.sfktime)
        this.sfktimeFlag = false
      }
      if (e.field_name === '开票时间') {
        this.$set(e, 'val', this.kpsj)
        this.kpsjFlag = false
      }
      if (e.field_name === '明细编号') {
        this.$set(e, 'val', this.formInline.region)
        this.kpsjFlag = false
      }
      for (let i = 1; i < 11; i++) {
        if (e.field_name === `下单日期${i}`) {
          this.$set(e, 'val', this.obj[`xdrq${i}`])
          this.obj[`xdrq${i}Flag`] = false
        }
        if (e.field_name === `广告内容${i}`) {
          this.$set(e, 'val', this.obj[`ggnr${i}`])
          this.obj[`ggnr${i}Flag`] = false
        }
        if (e.field_name === `尺寸${i}`) {
          this.$set(e, 'val', this.obj[`cc${i}`])
          this.obj[`cc${i}Flag`] = false
        }
        if (e.field_name === `数量${i}`) {
          this.$set(e, 'val', this.obj[`num${i}`])
          this.obj[`num${i}Flag`] = false
        }
        if (e.field_name === `喷绘性质${i}`) {
          this.$set(e, 'val', this.obj[`phxz${i}`])
          this.obj[`phxz${i}Flag`] = false
        }
        if (e.field_name === `上刊时间或换画时间派单上画${i}`) {
          this.$set(e, 'val', this.obj[`sksj${i}`])
          this.obj[`sksj${i}Flag`] = false
        }
        if (e.field_name === `供应商${i}`) {
          this.$set(e, 'val', this.obj[`gys${i}`])
          this.obj[`gys${i}Flag`] = false
        }
        if (e.field_name === `喷绘记录备注${i}`) {
          this.$set(e, 'val', this.obj[`phbz${i}`])
          this.obj[`phbz${i}Flag`] = false
        }
      }
      for (let i = 2; i < 5; i++) {
        if (e.field_name === `第${indexes[i - 2]}期应付金额`) {
          this.$set(e, 'val', this.money[`yfje${i}`])
          this.money[`yfje${i}Flag`] = false
        }
        if (e.field_name === `第${indexes[i - 2]}期开票时间`) {
          this.$set(e, 'val', this.money[`kpsj${i}`])
          this.money[`kpsj${i}Flag`] = false
        }
        if (e.field_name === `第${indexes[i - 2]}期发票号`) {
          this.$set(e, 'val', this.money[`fph${i}`])
          this.money[`fph${i}Flag`] = false
        }
        if (e.field_name === `第${indexes[i - 2]}期发票金额`) {
          this.$set(e, 'val', this.money[`fpje${i}`])
          this.money[`fpje${i}Flag`] = false
          console.log(this.money)
        }
        if (e.field_name === `第${indexes[i - 2]}期款到款时间`) {
          this.$set(e, 'val', this.money[`dksj${i}`])
          this.money[`dksj${i}Flag`] = false
        }
        if (e.field_name === `第${indexes[i - 2]}期备注`) {
          this.$set(e, 'val', this.money[`sybz${i}`])
          this.money[`sybz${i}Flag`] = false
        }
      }
      if (e.field_id <= 625 && e.field_id >= 611) {
        this.$set(e, 'val', this.wm[`wm${e.field_id}`])
      }
      if (e.field_id <= 24 && e.field_id >= 23) {
        this.$set(e, 'val', this.obj['obj' + e.field_id])
        this.obj['obj' + e.field_id + 'Flag'] = false
      }
      if (this.obj[`obj${e.approve_field_id}`] !== undefined && e.approve_field_id) {
        if (e.approve_field_id <= 24 && e.approve_field_id >= 23) {
          this.$set(e, 'val', this.obj['obj' + e.approve_field_id])
          this.obj['obj' + e.approve_field_id + 'Flag'] = false
        }
      }
      // console.log(this.field_ids, this.field_vals)
    }
  }
}
</script>
<style>
#demo-form-inline .el-select {
  width: 300px;
}
</style>
